using Gee;
using SQLHeavy;
using Meridian.Data;

namespace Meridian.Side.Recovery {

public class BookmarkFactory : RecoveryFactory<Bookmark> {

    public BookmarkFactory (Dao dao) {
        base (dao);
    }
    
    protected override Bookmark create_item (QueryResult records) {
	    
    	return new Bookmark.recover (
            records.get_string ("title"),
            records.get_string ("url"),
            records.get_int ("visits"),
            to_date (records.get_int64 ("added")),
            to_date (records.get_int64 ("last_visited")));        	
    }
    
    protected override Gee.List<DataOrder> get_order () {
        var order = new ArrayList<DataOrder> ();
        order.add (new DataOrder (DataDirection.DESC, "visits"));
        order.add (new DataOrder (DataDirection.DESC, "added"));
        return order;
    }
    
    protected override DataTable get_table () {
        return DataTable.BOOKMARK;
    }
    
}
}